//
//  LoginViewController.m
//  SimpleDemo
//
//  Created by tw001 on 15/8/1.
//  Copyright (c) 2015年 wave. All rights reserved.
//

#import "LoginViewController.h"
#import "MyPersonCenterViewController.h"
//#import "APService.h"


@interface LoginViewController ()

@property (nonatomic, strong)UITextField *textField0;   ///账号、手机
@property (nonatomic, strong)UITextField *textFiled1;   ///密码

@property (nonatomic, strong)UITextField *te;
//@property (nonatomic, strong)UILabel *errorLabel;    ///手机号码错误

@property (nonatomic, strong)UIButton *getBtn;///获取动态吗按钮

@property (nonatomic, strong)NSTimer *timer;////计时器
@property (nonatomic, strong)NSTimer *statusTimer;// 按钮状态计时器

@property (nonatomic, strong)UIButton *loginBtn;

@property (nonatomic, strong)UIButton *leftBtn;

@property (strong,nonatomic)UILabel *rightLabel;  //右侧注册按钮

@property (nonatomic, assign)NSInteger length;

@property (nonatomic, strong)UIView *loginingView;////登录转菊花
@property (nonatomic,strong) UITextField *textFiled;

@property (strong,nonatomic) UIImageView *logoView;  //登陆界面的logo
@property (strong,nonatomic) MyPersonCenterViewController *infoVC;
@property (strong,nonatomic) UIView *bgView;

@end

@implementation LoginViewController
-(void)dealloc
{
    NSLog(@"登陆页面释放。。。。。。。");
    [_timer invalidate];
    _timer = nil;
    [_statusTimer invalidate];
    _statusTimer = nil;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
    if (textField.text.length==0) {
        _loginBtn.layer.borderColor=[UIColor lightGrayColor].CGColor;
        [_loginBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    }
    else
    {
        _loginBtn.layer.borderColor=COLOR(36, 148, 88, 1).CGColor;
        [_loginBtn setTitleColor:COLOR(36, 148, 88, 1) forState:UIControlStateNormal];
    }
    return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    return YES;
}


- (void)textFieldDidEndEditing:(UITextField *)textField
{
    NSLog(@"textFieldDidEndEditing");
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    if ([textField.placeholder isEqualToString:@"  请输入手机号/邮箱"]) {
        
        [_textFiled1 becomeFirstResponder];
    }
    else
    {
        [_textFiled1 resignFirstResponder];
    }
    return YES;
}

-(void)viewWillAppear:(BOOL)animated
{
    NSLog(@"登录返回");
    [super viewWillAppear:animated];
    a = 60;
    if (!_timer) {
        _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeNum:) userInfo:nil repeats:YES];
        [_timer setFireDate:[NSDate distantFuture]];
    }
    if (!_statusTimer) {
        _statusTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(statusChange:) userInfo:nil repeats:YES];

    }
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSLog(@"xxxxdveiceHeight%f",[UIScreen mainScreen].bounds.size.height);
    
    
    //增加监听，当键盘出现或改变时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification
                                               object:nil];
    
    //增加监听，当键退出时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillHide:)
                                                 name:UIKeyboardWillHideNotification
                                               object:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hiddenSelf) name:@"hiddenSelf" object:nil];
    
    
    _bgView=[[UIView alloc]initWithFrame:CGRectMake(0,0,kDeviceWidth,kDeviceHeight)];
    _bgView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:_bgView];
    
    if (!_infoVC) {
        _infoVC=[[MyPersonCenterViewController alloc]init];
    }

    NSLog(@"登录页面将要显示");
    for (UIView *v in self.navigationController.navigationBar.subviews) {////这里的目的是把主页的种类按钮和地区按钮隐藏
        if ([v isKindOfClass:[UIButton class]]) {
            v.hidden = YES;
        }
    }
    self.navigationItem.title = @"登录";
    self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil, nil];
    
    _leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _leftBtn.frame = CGRectMake(5, 0, 35, 44);
    [_leftBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
//    [_leftBtn addTarget:self action:@selector(dismissToRoot) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_leftBtn];
    
    _logoView=[[UIImageView alloc]initWithFrame:CGRectMake(kDeviceWidth/12,40,kDeviceWidth/6*5,kDeviceHeight/3)];
    [_logoView setImage:[UIImage imageNamed:@"logo"]];
    _logoView.contentMode=UIViewContentModeScaleAspectFit;
    [_bgView addSubview:_logoView];
    
    
    _te = [self addTextFiledWithPlaceHolder:@"" andY:kDeviceHeight/3+64];
    _textField0 = [[UITextField alloc]initWithFrame:CGRectMake(22.5,kDeviceHeight/3+64, self.view.frame.size.width-50, 35)];
    _textField0.keyboardType = UIKeyboardTypeAlphabet;
    _textField0.placeholder = @"  请输入手机号/邮箱";
    [_bgView addSubview:_textField0];
    _textField0.inputAccessoryView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 0.35)];
    _textField0.inputAccessoryView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.6];
    _textField0.delegate=self;
    _textField0.returnKeyType=UIReturnKeyNext;
    [_textField0 addTarget:self action:@selector(limitLength:) forControlEvents:UIControlEventEditingChanged];
    
    [self addTextFiledWithPlaceHolder:@"" andY:0];
    _textFiled1 = [[UITextField alloc]initWithFrame:CGRectMake(22.5,_textField0.frame.origin.y+35+15, self.view.frame.size.width-30-70, 35)];
    _textFiled1.secureTextEntry = YES;
    _textFiled1.placeholder = @"  请输入登录密码/动态码";
    _textFiled1.delegate=self;
    _textFiled1.returnKeyType=UIReturnKeyGo;
    [_bgView addSubview:_textFiled1];
    if (LBXIsPad) {
        _textFiled1.keyboardType = UIKeyboardTypeNumberPad;
    }
    
    [self addTextFiledWithPlaceHolder:@"" andY:1];
    _getBtn=[[UIButton alloc]initWithFrame:CGRectMake(self.view.frame.size.width-90-5,_textFiled1.frame.origin.y,80,35)];
    _getBtn.layer.cornerRadius = 3;
    _getBtn.titleLabel.font = [UIFont systemFontOfSize:11];
    NSMutableAttributedString *astring=[[NSMutableAttributedString alloc]initWithString:@"获取动态码"];
    [astring addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0,5)];
    [_getBtn setAttributedTitle:astring forState:UIControlStateNormal];
    [_getBtn addTarget:self action:@selector(getCheckNum:) forControlEvents:UIControlEventTouchUpInside];
    [_bgView addSubview:_getBtn];
  
    _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _loginBtn.frame = CGRectMake(kDeviceWidth/2-75,_textFiled1.frame.origin.y+44+15,150, 35);
    _loginBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _loginBtn.layer.borderWidth=1;
    _loginBtn.layer.borderColor=[UIColor lightGrayColor].CGColor;
    [_loginBtn setTitle:@"登陆" forState:UIControlStateNormal];
    [_loginBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [_loginBtn addTarget:self action:@selector(loginBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
    _loginBtn.layer.cornerRadius = 3;
    [_loginBtn setExclusiveTouch:YES];
    [_loginBtn setEnabled:NO];
    [_bgView addSubview:_loginBtn];

    
    UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(endEdit:)];
    [self.view addGestureRecognizer:tap1];
    
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        
        self.navigationController.interactivePopGestureRecognizer.delegate = self;
        
    }
}

/////监视手机号码输入
- (void)limitLength:(UITextField *)sender
{
    
}

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
    NSLog(@"视图一出现");
}
- (void)endEdit:(UITapGestureRecognizer *)tap
{
    [self.view endEditing:YES];
}
- (UITextField *)addTextFiledWithPlaceHolder:(NSString *)placeHolder andY:(CGFloat)y
{
    if (y==kDeviceHeight/3+64) {
        _textFiled = [[UITextField alloc]initWithFrame:CGRectMake(15,y, self.view.frame.size.width-30 , 35)];
        _textFiled.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _textFiled.layer.cornerRadius = 2;
        _textFiled.backgroundColor = [UIColor whiteColor];
        _textFiled.layer.borderWidth = 0.5;
    }
    else if(y==0)
    {
        _textFiled = [[UITextField alloc]initWithFrame:CGRectMake(15,_textField0.frame.origin.y+35+15, self.view.frame.size.width-30-90, 35)];
        _textFiled.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _textFiled.layer.cornerRadius = 2;
        _textFiled.backgroundColor = [UIColor whiteColor];
        _textFiled.layer.borderWidth = 0.5;
    }
    else if(y==1)
    {
        _textFiled=[[UITextField alloc]initWithFrame:CGRectMake(self.view.frame.size.width-90-5,_textFiled1.frame.origin.y,80,35)];
        _textFiled.layer.borderColor = [UIColor orangeColor].CGColor;
        _textFiled.layer.cornerRadius = 5;
        _textFiled.layer.borderWidth = 0.5;
    }
   
    _textFiled.clipsToBounds=YES;
    
    _textFiled.userInteractionEnabled = NO;
    [_bgView addSubview:_textFiled];
    return _textFiled;
}

///获取动态码按钮
- (void)getCheckNum:(UIButton *)sender
{
    HLManager *lbxManager=[HLManager sharedManager];
    NSString *phone = [lbxManager makeDownWithTextField:_textField0];
    
    if ([lbxManager checkPhoneNum:phone]) {
        if ([lbxManager checkIsHasNetworkFunction]) {
            [_timer setFireDate:[NSDate distantPast]];///开始计时器
            [_getBtn setEnabled:NO];
            AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
            manager.responseSerializer = [AFHTTPResponseSerializer serializer];
            manager.requestSerializer.timeoutInterval = kTimeoutInterval;
            manager.securityPolicy = [lbxManager getHttpsSetting];

            // 填写表单
            NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
//            [dict setObject:[lbxManager makeDownWithTextField:_textField0] forKey:@"username"];
            [dict setObject:[lbxManager makeDownWithTextField:_textField0] forKey:@"mobile"];
            
            NSString *urlStr = [NSString stringWithFormat:@"%@front/member/getMobileVerifyCode.do",kServerNetwork];

            [manager POST:urlStr parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
                
            } success:^(AFHTTPRequestOperation *operation, id responseObject) {
                
                NSLog(@"responseObject = %@",responseObject);
                
                NSError *error = nil;
                NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&error];
                NSLog(@"DBXXXXXdict%@",dict);
                if ([[dict objectForKey:@"status"] intValue] != 1) {
                    [self setResetTimer];
                }
                
                UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"提示" message:[dict objectForKey:@"message"] delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
                [av show];
                
            }
                  failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                NSLog(@"error = %@",error.description);
                [self setResetTimer];
            }];
        }else{
            [lbxManager showHudText:@"网络连接失败" detailsText:nil afterDelay:1];
        }
    }else{
        
        UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"电话号码有误，请检查后重试。" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];
        [alertView show];
    }
    NSLog(@"获取动态码");
}

/// 回复计时器默认设置
- (void)setResetTimer
{
    [_timer setFireDate:[NSDate distantFuture]];///停止计时器，获取失败
    NSLog(@"短信发送失败");
    NSMutableAttributedString *astring=[[NSMutableAttributedString alloc]initWithString:@"获取动态码"];
    [astring addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0,5)];
    [_getBtn setAttributedTitle:astring forState:UIControlStateNormal];
    [_getBtn setEnabled:YES];
    a = 60;
}


///登录按钮
- (void)loginBtnClicked:(UIButton *)sender
{
    HLManager *lbxManager=[HLManager sharedManager];
    if (_textField0.text.length != 13 || [lbxManager checkPhoneNum:[lbxManager makeDownWithTextField:_textField0]]) {
        if (_textFiled1.text.length > 0) {
            if (!_loginingView) {
                _loginingView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
                _loginingView.backgroundColor = [UIColor clearColor];
                
                UIView *backGroundView = [[UIView alloc]initWithFrame:CGRectMake(self.bgView.frame.size.width/2.0-70, self.bgView.frame.size.height/2.0-70, 140, 140)];
                backGroundView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.7];
                backGroundView.layer.cornerRadius = 5;
                [_loginingView addSubview:backGroundView];
                
                UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(10, 0, 120, 120)];
                activityView.activityIndicatorViewStyle =  UIActivityIndicatorViewStyleWhiteLarge;
                //    activityView.backgroundColor = [UIColor lightGrayColor];
                [activityView startAnimating];
                [backGroundView addSubview:activityView];
                
                UILabel *logi = [[UILabel alloc]initWithFrame:CGRectMake(0, 100, backGroundView.frame.size.width, 25)];
                logi.text = @"登录中。。。";
                logi.textColor = [UIColor whiteColor];
                logi.font = [UIFont systemFontOfSize:17];
                logi.textAlignment = NSTextAlignmentCenter;
                [backGroundView addSubview:logi];
            }
            [self.bgView addSubview:_loginingView];
            [self test];

        }else{
            [lbxManager showHudText:@"密码不能为空" detailsText:nil afterDelay:3];
        }
    }else{
        [lbxManager showHudText:@"手机号输入有误" detailsText:nil afterDelay:3];
    }
    NSLog(@"登录。。。。。。。。。。。");
    [self.view endEditing:YES];
}

- (void)test
{
    HLManager *lbxManager=[HLManager sharedManager];
    if ([lbxManager checkIsHasNetworkFunction]) {
        
        AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
        manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        manager.requestSerializer.timeoutInterval = kTimeoutInterval;
        manager.securityPolicy = [lbxManager getHttpsSetting];

        [_statusTimer setFireDate:[NSDate distantFuture]];
        [_loginBtn setEnabled:NO];

        // 填写表单
        NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
        [dict setObject:[lbxManager makeDownWithTextField:_textField0] forKey:@"memberName"];
        [dict setObject:_textFiled1.text forKey:@"password"];
        
        NSString *urlStr = [NSString stringWithFormat:@"%@/front/member/mlogin.do",kServerNetwork];

        [manager POST:urlStr parameters:dict constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
            
        } success:^(AFHTTPRequestOperation *operation, id responseObject) {
            if (responseObject) {

                NSError *error = nil;
                NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:&error];
                NSLog(@"dic++++++ggg%@",dic);
                
                if ([[dic objectForKey:@"status"]intValue] == 1) {///登录成功
                    
                    NSMutableDictionary *dict=[[NSMutableDictionary alloc]initWithDictionary:[self fixDict:[dic objectForKey:@"data"]]];
                    
                    NSLog(@"dict++--%@",dict);
                    
                    [[NSUserDefaults standardUserDefaults]setObject:dict forKey:@"user"];
                    [[NSUserDefaults standardUserDefaults]synchronize];
                    
                    NSLog(@"%@",[[NSUserDefaults standardUserDefaults]objectForKey:@"user"]);
                    _infoVC.view.frame=CGRectMake(kDeviceWidth*2,0,kDeviceWidth, kDeviceHeight);
                    _textField0.text=nil;
                    _textFiled1.text=nil;
                    [self setResetTimer];
                    [self.view removeFromSuperview];
                
                    [self.view.superview addSubview:_infoVC.view];
                    [[NSNotificationCenter defaultCenter] postNotificationName:kGetSelfInfo object:nil];
                    [[NSNotificationCenter defaultCenter]postNotificationName:@"hidzucebtn" object:nil];

                }else{
                    [_statusTimer setFireDate:[NSDate distantPast]];
                    [_loginBtn setEnabled:YES];
                    [lbxManager showHudText:@"密码或验证码错误" detailsText:nil afterDelay:2];
                }
            }
            [_loginingView removeFromSuperview];
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            NSLog(@"error = %@",error.description);
            [_loginingView removeFromSuperview];
            [_loginBtn setEnabled:YES];
            [_statusTimer setFireDate:[NSDate distantPast]];
        }];

    }else{
        [_loginingView removeFromSuperview];
        [lbxManager showHudText:@"网络连接失败" detailsText:nil afterDelay:1];
    }
    
}
static int a = 60;
///计时器计算获取验证码的时间
- (void)changeNum:(NSTimer*)timer
{
    if (a > 0) {
        NSString *aString=[NSString stringWithFormat:@"%d",a];
        NSMutableAttributedString *Mutablestring=[[NSMutableAttributedString alloc]initWithString:aString];
        [Mutablestring addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0,aString.length)];
        
        [_getBtn setAttributedTitle:Mutablestring forState:UIControlStateNormal];
        a--;
    }else{
        NSMutableAttributedString *astring=[[NSMutableAttributedString alloc]initWithString:@"获取动态码"];
        [astring addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:NSMakeRange(0,5)];
        [_getBtn setAttributedTitle:astring forState:UIControlStateNormal];
        [_getBtn setEnabled:YES];
        [_timer setFireDate:[NSDate distantFuture]];
        a = 60;
    }
}


- (void)dismissToRoot
{

    [self.navigationController popToRootViewControllerAnimated:NO];
}

- (void)statusChange:(NSTimer *)timer
{
    if (_textField0.text.length && _textFiled1.text.length >= 6) {
        [_loginBtn setEnabled:YES];
//        [_loginBtn setBackgroundColor:kGreenColor];
    } else {
        [_loginBtn setEnabled:NO];
//        [_loginBtn setBackgroundColor:kGrayColor];
    }
}

-(void)viewDidDisappear:(BOOL)animated
{
   
    [_timer setFireDate:[NSDate distantFuture]];
    [_timer invalidate];
    _timer = nil;
    [_statusTimer setFireDate:[NSDate distantFuture]];
    [_statusTimer invalidate];
    _statusTimer = nil;
    [self.view endEditing:YES];
    [_getBtn setTitle:@"获取动态码" forState:UIControlStateNormal];
    [_getBtn setEnabled:YES];
    
    
}

-(void)keyboardWillShow:(NSNotification*)noti
{
    NSDictionary *userInfo = [noti userInfo];
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [aValue CGRectValue];
    
    if (kDeviceHeight==480.000000) {
        [UIView animateWithDuration:0.25 animations:^{
            _bgView.frame=CGRectMake(0,-keyboardRect.size.height+20,kDeviceWidth,kDeviceHeight);
        }];
    }else
    {
        [UIView animateWithDuration:0.25 animations:^{
            _bgView.frame=CGRectMake(0,-keyboardRect.size.height/2,kDeviceWidth,kDeviceHeight);
        }];
    }

}

-(void)keyboardWillHide:(NSNotification*)noti
{

  [UIView animateWithDuration:0.25 animations:^{
     _bgView.frame=CGRectMake(0,0,kDeviceWidth,kDeviceHeight);

  }];
}


-(NSMutableDictionary*)fixDict:(NSDictionary*)dict
{
    NSMutableDictionary *diction=[NSMutableDictionary dictionaryWithCapacity:10];
    
    NSLog(@"%@%@%@%@%@%@%@%@%@%@",[dict objectForKey:@"mobile"],[dict objectForKey:@"shopId"],[dict objectForKey:@"score"],[dict objectForKey:@"gender"],[dict objectForKey:@"memberName"],[dict objectForKey:@"email"],[dict objectForKey:@"memberId"],[dict objectForKey:@"token"],[dict objectForKey:@"avatarPath"],[dict objectForKey:@"nickName"]);
    
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"mobile"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"mobile"] forKey:@"mobile"];
    }
    else
    {
        [diction setValue:@"" forKey:@"mobile"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"shopId"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"shopId"] forKey:@"shopId"];
    }
    else
    {
        [diction setValue:@"" forKey:@"shopId"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"score"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"score"] forKey:@"score"];
    }
    else
    {
        [diction setValue:@"" forKey:@"score"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"gender"]] isEqualToString:@"<null>"]) {
        
        [diction setObject:[dict objectForKey:@"gender"] forKey:@"gender"];
    }
    else
    {
        [diction setValue:@"" forKey:@"gender"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"memberName"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"memberName"] forKey:@"memberName"];
    }
    else
    {
        [diction setValue:@"" forKey:@"memberName"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"email"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"email"] forKey:@"email"];
    }
    else
    {
        [diction setValue:@"" forKey:@"email"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"memberId"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"memberId"] forKey:@"memberId"];
    }
    else
    {
        [diction setValue:@"" forKey:@"memberId"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"token"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"token"] forKey:@"token"];
    }
    else
    {
        [diction setValue:@"" forKey:@"token"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"avatarPath"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"avatarPath"] forKey:@"avatarPath"];
    }
    else
    {
        [diction setValue:@"" forKey:@"avatarPath"];
    }
    if (![[NSString stringWithFormat:@"%@",[dict objectForKey:@"nickName"]] isEqualToString:@"<null>"]) {
        [diction setObject:[dict objectForKey:@"nickName"] forKey:@"nickName"];
    }
    else
    {
        [diction setValue:@"" forKey:@"nickName"];
    }
    return diction;
}

//注册成功后直接登录，使本页面消失
-(void)hiddenSelf
{
   [self.view removeFromSuperview];
}


@end
